package com.sw.haruka.helper.utils;

import android.content.Context;
import android.view.View;
import android.view.inputmethod.InputMethodManager;

/**
 * Created by Swsbty on 2021/05/22
 */
public class SoftInputManager {

    public static void hide(Context context, View view) {
        InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.hideSoftInputFromWindow(view.getWindowToken(), 0); //强制隐藏键盘
    }

    public static void show(Context context, View view) {
        operate(context, view, InputMethodManager.SHOW_FORCED);
    }

    public static void operate(Context context, View view, int offset) {
        InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.showSoftInput(view, offset);
    }

}
